using System;
using Microsoft.Xna.Framework;
using WindowsGame.Static;

namespace WindowsGame
{
	/// <summary>
	/// MyGame delegates all game actions to the GameManager.
	/// </summary>
	public class MyGame : Game
	{
		private readonly GraphicsDeviceManager graphics;
		private readonly IGameManager gameManager;

		public MyGame()
		{
			graphics = new GraphicsDeviceManager(this);
			Content.RootDirectory = Constants.ROOT_DIRECTORY;

			Registration.Initialize();
			gameManager = GameFactory.GetGameManager();
		}

		protected override void Initialize()
		{
			gameManager.Initialize(this, graphics);
			base.Initialize();
		}

		protected override void LoadContent()
		{
			gameManager.LoadContent();
			base.LoadContent();
		}

		protected override void UnloadContent()
		{
			gameManager.UnloadContent();
			base.UnloadContent();
		}

		protected override void Update(GameTime gameTime)
		{
			gameManager.Update(gameTime);
			base.Update(gameTime);
		}

		protected override void Draw(GameTime gameTime)
		{
			gameManager.Draw();
			base.Draw(gameTime);
		}

		protected override void OnExiting(object sender, EventArgs args)
		{
			gameManager.Exit();
			base.OnExiting(sender, args);
		}
	}
}